package com.wellink.android_demo;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.widget.CompoundButton;
import android.widget.Switch;
import android.widget.Toast;
import android.widget.ToggleButton;

public class MainActivity3 extends AppCompatActivity {

    private ToggleButton tb = null;
    private Switch sw = null;

    @Override
    protected void onCreate( Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.toggle_layout);

        tb = findViewById(R.id.like_tb);

        tb.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    Toast.makeText(MainActivity3.this,"Yes,I like it.",Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(MainActivity3.this,"No,I don't like it.",Toast.LENGTH_SHORT).show();
                }
            }
        });

        sw = findViewById(R.id.blue_switch);
        sw.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                if(isChecked){
                    Toast.makeText(MainActivity3.this,"Yes,Open BlueTooth",Toast.LENGTH_SHORT).show();
                }else{
                    Toast.makeText(MainActivity3.this,"No,Close BlueTooth",Toast.LENGTH_SHORT).show();
                }
            }
        });
    }
}
